<?
/**
* Copyright (c) 2002-2007 BioWare Corp.
* http://www.bigdaddymonitor.org
*
* This file is part of the BigDaddy Monitoring
* program. It is free software distributed under
* the terms of the BSD License. It is ditributed
* in the hopes that it will be useful, but
* WITHOUT ANY WARRANTY; without event the implied
* warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.
*
* The BSD License is available from:
* http://www.opensource.org/licenses/bsd-license.php
**/
//=============================================================//
//Query File for Server Module Control (BigDaddy v2)
//Duleepa Wijyawardhana, 26.03.2004
//=============================================================//


switch($_REQUEST["action"])
{
    case "addmod":
	
		$aInfo["serverID"] = $_POST["serverID"];
		$aInfo["modID"] = $_POST["modID"];
		$aInfo["iniID"] = $_POST["iniID"];
		$aInfo["mon_startlevel"] = $_POST["mon_startlevel"];
		$aInfo["lastreport_threshold"] = $_POST["lastreport_threshold"];
		$aInfo["mon_endlevel"] = $_POST["mon_endlevel"];
		$aInfo["parameters"] = $_POST["parameters"];
		
		$BigDaddyControl->SetServerMod($aInfo);
		$redirectTo="page=ServerViewDetails&serverID=".$_POST["serverID"];
        break;
    case "editmod":
	
		$aInfo["serverID"] = $_POST["serverID"];
		$aInfo["modID"] = $_POST["modID"];
		$aInfo["iniID"] = $_POST["iniID"];
		$aInfo["mon_startlevel"] = $_POST["mon_startlevel"];
		$aInfo["lastreport_threshold"] = $_POST["lastreport_threshold"];
		$aInfo["mon_endlevel"] = $_POST["mon_endlevel"];
		$aInfo["parameters"] = $_POST["parameters"];
	
		$BigDaddyControl->SetServerMod($aInfo, $_POST["ID"]);
	
        $redirectTo="page=ServerViewDetails&serverID=".$_POST["serverID"];
        break;
    case "enablemod":
	
		$BigDaddyControl->SetServerModStatusEnabled($_REQUEST["ID"], $_REQUEST["serverID"]);

		if ($_SESSION["sessdata"]["pagefrom"] != "")
		{
			$redirectTo=$_SESSION["sessdata"]["pagefrom"];
		}
		else
		{
			$redirectTo="page=ServerViewDetails&serverID=".$_REQUEST["serverID"];
		}
        break;
    case "disablemod":
	
		$BigDaddyControl->SetServerModStatusDisabled($_REQUEST["ID"], $_REQUEST["serverID"]);
		
		if ($_SESSION["sessdata"]["pagefrom"] != "")
		{
			$redirectTo=$_SESSION["sessdata"]["pagefrom"];
		}
		else
		{
			$redirectTo="page=ServerViewDetails&serverID=".$_REQUEST["serverID"];
		}
        break;
    case "deletemod":
	
		$BigDaddyControl->RemoveServerMod($_REQUEST["ID"], $_REQUEST["serverID"]);
		
		if ($_SESSION["sessdata"]["pagefrom"] != "")
		{
			$redirectTo=$_SESSION["sessdata"]["pagefrom"];
		}
		else
		{
			$redirectTo="page=ServerViewDetails&serverID=".$_REQUEST["serverID"];
		}
        break;
    case "delaymod":

		$delayUntil=mktime($_POST["hourselect"],$_POST["minuteselect"], 0, $_POST["monthselect"], $_POST["dayselect"], $_POST["yearselect"]);	
		$BigDaddyControl->SetServerModStatusDelayed($_REQUEST["ID"], $delayUntil, $_REQUEST["serverID"]);
		
		if ($_SESSION["sessdata"]["pagefrom"] != "")
		{
			$redirectTo=$_SESSION["sessdata"]["pagefrom"];
		}
		else
		{
			$redirectTo="page=ServerViewDetails&serverID=".$_REQUEST["serverID"];
		}
        break;
    case "copymod":
	
		$BigDaddyControl->SetServerModCopy($_POST["copyServerID"], $_POST["serverID"], $_POST["copyModuleID"]);
		$redirectTo="page=ServerViewDetails&serverID=".$_POST["serverID"];
		break;
    case "copyallmod":
		$BigDaddyControl->SetServerModCopyAll($_POST["copyServerID"], $_POST["serverID"]);
		$redirectTo="page=ServerViewDetails&serverID=".$_POST["serverID"];
	break;

}



if ($redirectTo!="")
{
    header("Location: /index.html?".$redirectTo);
    exit;
}
else
{
    header("Location: /index.html");
    exit;
}

?>
